package player_single

//go:generate msgp

//msgp:tuple PlayerSingleExtend
type PlayerSingleExtend struct {
	Key            string `json:"key" msg:"key"`
	LeaderboardKey string `json:"leaderboard_key" msg:"leaderboard_key"`
	BestTime       int    `json:"bestTime" msg:"bestTime"`
	BestScore      int    `json:"bestScore" msg:"bestScore"`
	Star           int    `json:"star" msg:"star"`
	Pass           bool   `json:"pass" msg:"pass"`
	UserBestTime   int    `json:"userBestTime" msg:"userBestTime"`
	UserBestScore  int    `json:"userBestScore" msg:"userBestScore"`
	UserRank       int    `json:"userRank" msg:"userRank"`
	//BaseTime       int    `json:"baseTime" msg:"baseTime"`
}

func NewPlayerSingleExtend(single *PlayerSingle, userSingle *PlayerUserSingle) *PlayerSingleExtend {
	extend := &PlayerSingleExtend{
		Key:            single.Key,
		LeaderboardKey: single.LeaderboardKey,
		BestTime:       single.BestTime,
		BestScore:      single.BestScore,
		Star:           0,
		Pass:           false,
		UserBestTime:   0,
		UserBestScore:  0,
		UserRank:       0,
		//BaseTime:       single.BaseTime,
	}
	if userSingle != nil {
		extend.Star = userSingle.Star
		extend.Pass = userSingle.Pass
		extend.UserBestTime = userSingle.BestTime
		extend.UserBestScore = userSingle.BestScore
		extend.UserRank = userSingle.Rank
	}

	return extend
}

//msgp:tuple SingleResult
type SingleResult struct {
	Star  int  `json:"star" msg:"star"`
	Pass  bool `json:"pass" msg:"pass"`
	Score int  `json:"score" msg:"score"`
	Time  int  `json:"time" msg:"time"`
	Rank  int  `json:"rank" msg:"rank"`
}
